package com.atguigu.gmall.model.list;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 *  映射对象   映射到ES索引库    Lucene实现在  Document文档类型  数据类型
 *
 *  indexName ： 索引库 库名
 *  type： 表名  废弃了
 *
 *  shards = 3： 分片
 *
 *  replicas = 2 ：2个副本
 */
@Document(indexName = "goods", shards = 3, replicas = 2)
@Data
public class Goods implements Serializable {//  Java代码 最终是转换成DSL语句 发给ES
    // ES  Mappings 映射

    @Id
    private Long id;//库存ID  skuId

    @Field(type = FieldType.Keyword, index = false)
    private String defaultImg;//type=FieldType 二种 分

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String title;

    @Field(type = FieldType.Double)
    private Double price;

    @Field(type = FieldType.Date)
    private Date createTime; // 新品

    @Field(type = FieldType.Long)
    private Long tmId;

    @Field(type = FieldType.Keyword)
    private String tmName;

    @Field(type = FieldType.Keyword)
    private String tmLogoUrl;

    @Field(type = FieldType.Long)
    private Long category1Id;

    @Field(type = FieldType.Keyword)
    private String category1Name;

    @Field(type = FieldType.Long)
    private Long category2Id;

    @Field(type = FieldType.Keyword)
    private String category2Name;

    @Field(type = FieldType.Long)
    private Long category3Id;

    @Field(type = FieldType.Keyword)
    private String category3Name;

    @Field(type = FieldType.Long)
    private Long hotScore = 0L;//热度 ： 关注度

    @Field(type = FieldType.Nested) //嵌套类型
    private List<SearchAttr> attrs;//平台属性集合

}
